#ifndef DF_COMMAND_IN_H_
#define DF_COMMAND_IN_H_
#include "command.h"
#include "ctType.h"

#pragma pack(1)
namespace Cmd
{
        namespace DiscussFactory
        {
                enum {
                        CMDIN_LOGIN             = 0x0010,	// 登录DFServer验证指令
                        CMDIN_FORWARD           = 0x0011,	// 转发的指令
                        CMDIN_SESSION           = 0x0012,	// 与SessionServer交互的指令
                        CMDIN_DISCUSS           = 0x0013,       // 与DiscussServer交互的指令
                };
                enum { //CMDIN_LOGIN
                        SCMDIN_LOGIN_REQ                        = 0x0001,	// 请求登录请求
                        SCMDIN_LOGIN_RES                        = 0x0002,	// 登录验证返回
                };
                enum { //CMDIN_FORWARD
                        SCMDIN_FORWARD_DF                       = 0x0001,       // 转发到DFServer的指令
                        SCMDIN_FORWARD_USER                     = 0x0002,	// DFServer转发指令给用户
                };
                enum { //CMDIN_SESSION
                        SCMDIN_SESSION_D_LOCATION_REQ           = 0x0001,
                        SCMDIN_SESSION_D_LOCATION_RES           = 0x0002,
                        SCMDIN_SESSION_D_LOCATION_NOTIFY_ADD    = 0x0003,
                        SCMDIN_SESSION_D_LOCATION_NOTIFY_DEL    = 0x0004,
                        SCMDIN_SESSION_USER_DISCUSS_LIST_REQ    = 0x0005,
                        SCMDIN_SESSION_USER_DISCUSS_LIST_RES    = 0x0006,
                };
                enum { //CMDIN_DISCUSS
                        SCMDIN_DISCUSS_ACTIVE_NOTIFY            = 0x0001,
                        SCMDIN_DISCUSS_LOAD_REQ                 = 0x0002,        // DF通知DiscussServer 加载讨论组,
                        SCMDIN_DISCUSS_LOAD_RES                 = 0x0003,        // DF通知DiscussServer 加载讨论组返回
                        SCMDIN_DISCUSS_MEMBER_LIST_REQ          = 0x0004,
                        SCMDIN_DISCUSS_MEMBER_LIST_RES          = 0x0005,
                        SCMDIN_DISCUSS_ADD_NEW_MEMBER_REQ       = 0x0006,
                        SCMDIN_DISCUSS_ADD_NEW_MEMBER_RES       = 0x0007,
                        SCMDIN_DISCUSS_UPDATE_TOPIC_REQ         = 0x0008,
                        SCMDIN_DISCUSS_LIST_REQ                 = 0x0009,
                        SCMDIN_DISCUSS_LIST_RES                 = 0x000A,
                        SCMDIN_DISCUSS_DEL_MEMBER_REQ           = 0x000B,       // DF->Discuss
                        SCMDIN_DISCUSS_DESTROY_REQ              = 0x000C,       // DF->Discuss
                        SCMDIN_DISCUSS_NOTIFY_RECYCLE_TIMEOUT   = 0x000D,       // DF->Discuss
                        SCMDIN_DISCUSS_MEMBER_UNREAD_MSG_NUM_NOTIRY     = 0x000E,       // Discuss->DF
                        SCMDIN_DISCUSS_USER_LIMIT_UPDATE        = 0x000F,
                };

                struct stLoginCmdReq:
                        t_NullCmd
                {
                        stLoginCmdReq():
                                t_NullCmd(CMDIN_LOGIN, SCMDIN_LOGIN_REQ)
                        {
                                dest_type_ = DISCUSSFACTORYSERVER;
                                server_type_ = 0;
                                server_id_ = 0;
                        }
                        WORD dest_type_;
                        WORD server_type_;
                        DWORD server_id_;
                };
                struct stLoginCmdRes:
                        t_NullCmd
                {
                        stLoginCmdRes():
                                t_NullCmd(CMDIN_LOGIN, SCMDIN_LOGIN_RES)
                        {
                        }
                };

                struct stForwardDF:
                        t_NullCmd
                {
                        stForwardDF():
                                t_NullCmd(CMDIN_FORWARD, SCMDIN_FORWARD_DF)
                        {
                                user_id_ = 0;
                                size_ = 0;
                        }
                        DWORD user_id_;
                        WORD size_;
                        BYTE data_[0];
                        DWORD getSize() 
                        {
                                return sizeof(*this)+size_*sizeof(data_[0]);
                        }
                };
                struct stForwardUser:
                        t_NullCmd
                {
                        stForwardUser():
                                t_NullCmd(CMDIN_FORWARD, SCMDIN_FORWARD_USER)
                        {
                                user_id_ = 0;
                                size_ = 0;
                        }
                        DWORD user_id_;
                        WORD size_;
                        BYTE data_[0];
                        DWORD getSize() 
                        {
                                return sizeof(*this)+size_*sizeof(data_[0]);
                        }
                };

                struct stSessionDiscussLocationReq:
                        t_NullCmd
                {
                        stSessionDiscussLocationReq():
                                t_NullCmd(CMDIN_SESSION, SCMDIN_SESSION_D_LOCATION_REQ)
                        {
                                discuss_id_ = 0;
                                user_id_ = 0;
                                cmd_type_= 0;
                                cmd_len_ = 0;
                        }
                        DWORD discuss_id_;
                        DWORD user_id_;
                        BYTE cmd_type_; //0-user Cmd; 1-server inner cmd
                        WORD cmd_len_;
                        BYTE cmd_data_[0];
                        DWORD getSize()
                        {
                                return sizeof(*this) + cmd_len_*sizeof(cmd_data_[0]);
                        }
                };
                struct stSessionDiscussLocationRes:
                        t_NullCmd
                {
                        stSessionDiscussLocationRes():
                                t_NullCmd(CMDIN_SESSION, SCMDIN_SESSION_D_LOCATION_RES)
                        {
                                discuss_id_ = 0;
                                user_id_ = 0;
                                server_id_ = 0;
                                cmd_type_ = 0;
                                cmd_len_ = 0;
                        }
                        DWORD discuss_id_;
                        DWORD user_id_;
                        WORD server_id_;
                        BYTE cmd_type_; //0-user cmd; 1-server inner cmd
                        WORD cmd_len_;
                        BYTE cmd_data_[0];
                        DWORD getSize()
                        {
                                return sizeof(*this) + cmd_len_*sizeof(cmd_data_[0]);
                        }
                };
                struct stSessionDiscussLocationSyncRes:
                        t_NullCmd
                {
                        stSessionDiscussLocationSyncRes():
                                t_NullCmd()
                        {
                                num_ = 0;
                        }
                        WORD num_;
                        struct stLocationInfo {
                                DWORD discussid;
                                WORD serverid;
                        } list_[0];
                        DWORD getSize() {
                                return sizeof(*this)+num_*sizeof(list_[0]);
                        }
                };
                struct stSessionDiscussLocationNotifyAdd:
                        t_NullCmd
                {
                        stSessionDiscussLocationNotifyAdd():
                                t_NullCmd(CMDIN_SESSION, SCMDIN_SESSION_D_LOCATION_NOTIFY_ADD)
                        {
                                discuss_id_ = 0;
                                server_id_ = 0;
                        }
                        DWORD discuss_id_;
                        DWORD server_id_;
                };
                struct stSessionDiscussLocationNotifyDel:
                        t_NullCmd
                {
                        stSessionDiscussLocationNotifyDel():
                                t_NullCmd(CMDIN_SESSION, SCMDIN_SESSION_D_LOCATION_NOTIFY_DEL)
                        {
                                discuss_id_ = 0;
                        }
                        DWORD discuss_id_;
                };
                struct stSessionUserDiscussListReq:
                        t_NullCmd
                {
                        stSessionUserDiscussListReq():
                                t_NullCmd(CMDIN_SESSION, SCMDIN_SESSION_USER_DISCUSS_LIST_REQ)
                        {
                                user_id_ = 0;
                        }
                        DWORD user_id_;
                };
                struct stSessionUserDiscussListRes:
                        t_NullCmd
                {
                        stSessionUserDiscussListRes():
                                t_NullCmd(CMDIN_SESSION, SCMDIN_SESSION_USER_DISCUSS_LIST_RES)
                        {
                                user_id_ = 0;
                                num_ =0 ;
                        }
                        DWORD user_id_;
                        WORD num_;
                        DWORD discuss_list_[0];
                        DWORD getSize() {
                                return sizeof(*this) + num_*sizeof(discuss_list_[0]);
                        }
                };
                
                struct stDiscussActiveNotify:
                        t_NullCmd
                {
                        stDiscussActiveNotify():
                                t_NullCmd(CMDIN_DISCUSS, SCMDIN_DISCUSS_ACTIVE_NOTIFY)
                        {
                                discuss_id_ = 0;
                                active_time_ = 0;
                                chat_time_ = 0;
                        }
                        DWORD discuss_id_;
                        DWORD active_time_;
                        DWORD chat_time_;
                };
                struct stDiscussLoadReq:
                        t_NullCmd
                {
                        stDiscussLoadReq():
                                t_NullCmd(CMDIN_DISCUSS, SCMDIN_DISCUSS_LOAD_REQ)
                        {
                                discuss_id_ = 0;
                                bzero(discuss_topic_, sizeof(discuss_topic_));
                                create_time_ = 0;
                                active_time_ = 0;
                                last_chat_time_ = 0;
                                creator_id_ = 0;
                                bzero(creator_name_, sizeof(creator_name_));
                                bzero(creator_nickname_, sizeof(creator_nickname_));
                                user_limit_ = 0;
                                msg_id_ = 0;
                        }
                        DWORD discuss_id_;
                        char  discuss_topic_[MAX_DISCUSS_TOPIC_LEN+1];
                        DWORD create_time_;
                        DWORD active_time_;
                        DWORD last_chat_time_;
                        DWORD creator_id_;
                        char  creator_name_[MAX_ACCOUNT_SIZE+1];
                        char  creator_nickname_[MAX_NAME_SIZE+1];
                        WORD  user_limit_;
                        DWORD msg_id_;
                };
                struct stDiscussLoadRes:
                        t_NullCmd
                {
                        stDiscussLoadRes():
                                t_NullCmd(CMDIN_DISCUSS, SCMDIN_DISCUSS_LOAD_RES)
                        {
                                discuss_id_ = 0;
                                ret_code_ = 0;
                        }
                        DWORD discuss_id_;
                        BYTE ret_code_;
                };
                struct stDiscussMemberListReq:
                        t_NullCmd
                {
                        stDiscussMemberListReq():
                                t_NullCmd(CMDIN_DISCUSS, SCMDIN_DISCUSS_MEMBER_LIST_REQ)
                        {
                                discuss_id_ = 0;
                        }
                        DWORD discuss_id_;
                };
                struct stDiscussMemberListRes:
                        t_NullCmd
                {
                        stDiscussMemberListRes():
                                t_NullCmd(CMDIN_DISCUSS, SCMDIN_DISCUSS_MEMBER_LIST_RES)
                        {
                                discuss_id_ = 0;
                                num_ = 0;
                        }
                        DWORD discuss_id_;
                        WORD  num_;
                        struct {
                                DWORD user_id_;
                                char account_[MAX_ACCOUNT_SIZE+1];
                                char nickname_[MAX_NAME_SIZE+1];
                                WORD unread_msg_;
                                DWORD read_msg_id_;
                        } user_list_[0];
                        DWORD getSize() {
                                return sizeof(*this)+num_*sizeof(user_list_[0]);
                        }
                };

                struct stDiscussAddNewMemberReq:
                        t_NullCmd
                {
                        stDiscussAddNewMemberReq():
                                t_NullCmd(CMDIN_DISCUSS, SCMDIN_DISCUSS_ADD_NEW_MEMBER_REQ)
                        {
                                discuss_id_ = 0;
                                request_id_ = 0;
                                request_server_id_ = 0;
                                user_num_   = 0;
                        }
                        DWORD discuss_id_;
                        DWORD request_id_;
                        WORD  request_server_id_;
                        WORD  user_num_;
                        DWORD user_list_[0];
                        DWORD getSize() {
                                return sizeof(*this)+user_num_*sizeof(user_list_[0]);
                        }
                };
                struct stDiscussAddNewMemberRes:
                        t_NullCmd
                {
                        stDiscussAddNewMemberRes():
                                t_NullCmd(CMDIN_DISCUSS, SCMDIN_DISCUSS_ADD_NEW_MEMBER_RES)
                        {
                                discuss_id_ = 0;
                                request_id_ = 0;
                                request_server_id_ = 0;
                                user_num_   = 0;
                        }
                        DWORD discuss_id_;
                        DWORD request_id_;
                        WORD  request_server_id_;
                        WORD  user_num_;
                        struct {
                                DWORD user_id_;
                                char account_[MAX_ACCOUNT_SIZE+1];
                                char nickname_[MAX_NAME_SIZE+1];
                                BYTE result_; //0-fail 1-success
                        } user_list_[0];
                        DWORD getSize() {
                                return sizeof(*this) + user_num_*sizeof(user_list_[0]);
                        }
                };
                struct stDiscussUpdateTopicReq:
                        t_NullCmd
                {
                        stDiscussUpdateTopicReq():
                                t_NullCmd(CMDIN_DISCUSS, SCMDIN_DISCUSS_UPDATE_TOPIC_REQ)
                        {
                                discuss_id_=0;
                                bzero(topic_, sizeof(topic_));
                        }
                        DWORD discuss_id_;
                        char topic_[MAX_DISCUSS_TOPIC_LEN+1];
                };
                struct stDiscussListReq:
                        t_NullCmd
                {
                        stDiscussListReq():
                                t_NullCmd(CMDIN_DISCUSS, SCMDIN_DISCUSS_LIST_REQ)
                        {
                        }
                };
                struct stDiscussListRes:
                        t_NullCmd
                {
                        stDiscussListRes():
                                t_NullCmd(CMDIN_DISCUSS, SCMDIN_DISCUSS_LIST_RES)
                        {
                                num_ = 0;
                        }
                        WORD num_;
                        DWORD list_[0];
                        DWORD getSize()
                        {
                                return sizeof(*this) + num_*sizeof(list_[0]);
                        }
                };
                struct stDiscussDelMemberReq:
                        t_NullCmd
                {
                        stDiscussDelMemberReq():
                                t_NullCmd(CMDIN_DISCUSS, SCMDIN_DISCUSS_DEL_MEMBER_REQ)
                        {
                                discuss_id_ = 0;
                                user_id_ = 0;
                        }
                        DWORD discuss_id_;
                        DWORD user_id_;
                };
                struct stDiscussDestroyReq:
                        t_NullCmd
                {
                        stDiscussDestroyReq():
                                t_NullCmd(CMDIN_DISCUSS, SCMDIN_DISCUSS_DESTROY_REQ)
                        {
                                discuss_id_ = 0;
                        }
                        DWORD discuss_id_;
                };
                struct stDiscussNotifyRecycleTimeOut:
                        t_NullCmd
                {
                        stDiscussNotifyRecycleTimeOut():
                                t_NullCmd(CMDIN_DISCUSS, SCMDIN_DISCUSS_NOTIFY_RECYCLE_TIMEOUT)
                        {
                                discuss_id_ = 0;
                        }
                        DWORD discuss_id_;
                };

                struct stDiscussMemberUnreadMsgNumNotify:
                        t_NullCmd
                {
                        stDiscussMemberUnreadMsgNumNotify():
                                t_NullCmd(CMDIN_DISCUSS, SCMDIN_DISCUSS_MEMBER_UNREAD_MSG_NUM_NOTIRY)
                        {
                                discuss_id_ = 0;
                                user_id_    = 0;
                                msg_num_    = 0;
                                msg_id_     = 0;
                        }
                        DWORD discuss_id_;
                        DWORD user_id_;
                        WORD  msg_num_;
                        DWORD msg_id_;
                };
                struct stDiscussUserLimitUpdate:
                        t_NullCmd
                {
                        stDiscussUserLimitUpdate():
                                t_NullCmd(CMDIN_DISCUSS, SCMDIN_DISCUSS_USER_LIMIT_UPDATE)
                        {
                                discuss_id_ = 0;
                                user_limit_ = DISCUSS_MEMBER_DEFAULT_LIMIT;
                        }
                        DWORD discuss_id_;
                        WORD  user_limit_;
                };
        }; //DiscussFactory
}; //Cmd

#pragma pack()
#endif //DF_COMMAND_IN_H_
